package com.wicket.okrcomponent.biz.service.nb;

import com.wicket.okrcomponent.biz.service.dto.common.AdjustMainNavigationSortingDto;
import com.wicket.okrcomponent.biz.service.dto.common.AgreedNavigationSortingDatasetDto;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import com.wicket.okrcomponent.biz.service.dto.req.ImplementAdjustMainNavigationSortingReqDto;
import com.wicket.okrcomponent.biz.service.dto.res.ImplementAdjustMainNavigationSortingRespDto;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ： 手工接入方法
 * @since 2022/5/28 15:32
 *
 *
 * @version 1.0
 */
@Service
public class NbMobileEndShell {
/**
      * code:adjustMainNavigationSorting
      * name:M2执行调整主导航排序（特殊方法）
      * desc:undefined
      * gen by moon at 4/1/2024, 1:34:55 AM
      * 
      **/
     @Trace(operationName = "M2执行调整主导航排序（特殊方法）")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public ImplementAdjustMainNavigationSortingRespDto implementAdjustMainNavigationSorting(ImplementAdjustMainNavigationSortingReqDto reqDto) {
         ImplementAdjustMainNavigationSortingRespDto retData = new ImplementAdjustMainNavigationSortingRespDto();
         Map<String,String> specIndex = new HashMap<>();
         for(AgreedNavigationSortingDatasetDto one : reqDto.getAgreedNavigationSortingDatasetList()){
             specIndex.put(one.getMenuCode(),one.getMenuOrderNumber());
         }
         Map<String,AdjustMainNavigationSortingDto> adjustIndex = new HashMap<>();
         for(AdjustMainNavigationSortingDto one : reqDto.getAdjustMainNavigationSortingList()){
             if(specIndex.containsKey(one.getMenuCode())){
                 one.setMenuOrderNumber(specIndex.get(one.getMenuCode()));
             }
             adjustIndex.put(one.getMenuCode(),one);
         }

         if(reqDto.getCustomField1()!=null){
             if(adjustIndex.containsKey("myLeaderPlan")){
                 AdjustMainNavigationSortingDto adjustResult = adjustIndex.get("myLeaderPlan");
                 adjustResult.setMenuIsVisible(reqDto.getCustomField1());
             }
         }
         if(reqDto.getCustomField2()!=null){
             if(adjustIndex.containsKey("mySubordinatePlan")){
                 AdjustMainNavigationSortingDto adjustResult = adjustIndex.get("mySubordinatePlan");
                 adjustResult.setMenuIsVisible(reqDto.getCustomField2());
             }

         }
         if(reqDto.getCustomField3()!=null){
             if(adjustIndex.containsKey("myDeptPlan")){
                 AdjustMainNavigationSortingDto adjustResult = adjustIndex.get("myDeptPlan");
                 adjustResult.setMenuIsVisible(reqDto.getCustomField3());
             }
         }
         if(reqDto.getCustomField4()!=null){
             if(adjustIndex.containsKey("spacePlan")){
                 AdjustMainNavigationSortingDto adjustResult = adjustIndex.get("spacePlan");
                 adjustResult.setMenuIsVisible(reqDto.getCustomField4());
             }
         }
        return retData;
      }
  //手工接入方法
}
